/*
 * PhysicsComponent.cpp
 *	implementation
 *  Created on: Oct 7, 2012
 *      Author: pigmal
 */

#include"PhysicsComponent.h"
#include <conprint.h>

PhysicsComponent::PhysicsComponent()
{
	Body = NULL;
}

PhysicsComponent::~PhysicsComponent()
{
	//the Body* is created and destrooyed by the b2World object
	Body = NULL;

}

//create a b2Body object (managed by the b2World) with b2BodyDef setup
bool PhysicsComponent::Init(b2World *world, const b2BodyDef *bodyDef)
{
	if(!world || !bodyDef)
	{
		lprintfln(" >> ERROR << PhysicsComponent::Init - wrong vals passed!");
		return false;
	}

	Body = world->CreateBody(bodyDef);
	if(!Body)
	{
		lprintfln(" >> ERROR << PhysicsComponent::Init - failed to create Body!");
		return false;
	}

	return true;
}

